package www.way2inbox.font;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.EditText;

public class Customfont_Edit extends EditText {

	 private Context context;
	    private AttributeSet attrs;
	    private int defStyle;

	    public Customfont_Edit(Context context) {
	        super(context);
	        this.context=context;
	        init();
	    } 

	     public Customfont_Edit(Context context, AttributeSet attrs) {
	          super(context, attrs);
	          this.context=context;
	          this.attrs=attrs;
	          init();
	     }

	    public Customfont_Edit(Context context, AttributeSet attrs, int defStyle) {
	          super(context, attrs, defStyle);
	          this.context=context;
	          this.attrs=attrs;
	          this.defStyle=defStyle;
	          init();
	    }

	    private void init() {
	          Typeface font=Typefaces.getTypeFace(getContext(), "/fonts/Roboto-Regular.ttf");
	          this.setTypeface(font);
	    }
//	    @Override
//	    public void setTypeface(Typeface tf, int style) {
//	        tf=Typeface.createFromAsset(getContext().getAssets(), "fonts/myfont.ttf");
//	        super.setTypeface(tf, style);
//	    }
//
//	    @Override
//	    public void setTypeface(Typeface tf) {
//	        tf=Typeface.createFromAsset(getContext().getAssets(), "fonts/myfont.ttf");
//	        super.setTypeface(tf);
//	    }
	    
	    @Override
	    public void setTypeface(Typeface tf, int style) {

	        //This is to override eclipse error messages
	        if (!super.isInEditMode()) {      

	            if (style == Typeface.BOLD) { 
	                super.setTypeface(Typefaces.getTypeFace(getContext(), "/fonts/Roboto-Bold.ttf"));
	                
	            }else if (style == Typeface.NORMAL){
	                super.setTypeface(Typefaces.getTypeFace(getContext(), "/fonts/Roboto-Light.ttf"));
	            }else{
	                super.setTypeface(Typefaces.getTypeFace(getContext(), "/fonts/Roboto-Regular.ttf"));
	            }
	        } 
	    }

}
